<#import "macro.ftl" as m>
<@m.page_header title='添加金融资产出入库记录' />
<div id="page-content-wrapper">
	<div id="page-title">
		<h3><a class="font-blue" href="/financialassets">金融资产</a> > 
		<a class="font-blue" href="/financialassets/${financialAssetStockEntry.financialAsset.id}/products">已发售产品</a> > 
		添加出入库记录<h3>
	</div>
	<!-- #page-title -->
	<div id="page-content">
		<#if error??>
			<div class="infobox error-bg mrg20B">
                <p>${error}</p>
            </div>
		</#if>
		<form id="form" action="/financialassetstockentries" method="post">
		<div class="row">
			<div class="col-md-10">
				<div class="form-row">
		            <div class="form-label col-md-2">
		                <label for="name">金融资产：</label>
		            </div>
		            <div class="form-label col-md-10">
		            	<input name="financialAsset.id" value="${financialAssetStockEntry.financialAsset.id}" type="hidden">
		                <label for="name">${financialAsset.name}</label>
		            </div>
		    	</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-10">
				<div class="form-row">
		            <div class="form-label col-md-2">
		                <label for="product.id">产品：</label>
		            </div>
		            <div class="form-input col-md-10">
		            	<select id="product.id" name="product.id">
			                <#list products as product>
			                	<option value="${product.id}" <#if financialAssetStockEntry.product?? && financialAssetStockEntry.product.id==product.id>selected</#if> >${product.name}</option>
			                </#list>
		                </select>
		            </div>
		    	</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-5">
				<div class="form-row">
		            <div class="form-label col-md-4">
		                <label for="purpose">用途：</label>
		            </div>
		            <div class="form-input col-md-8">
		                <select id="purpose" name="purpose">
		            		<option value="SoldInStock">结束销售，余额入库</option>
		            		<option value="Oversell">超卖，超出金额出库</option>
		            		<option value="PaymentCollection">用户回款</option>
		            		<option value="Sale">发售产品</option>
		                </select>
		            </div>
		    	</div>
			</div>
			<div class="col-md-5">
				<div class="form-row">
		            <div class="form-label col-md-4">
		                <label for="stockAmount">金额：</label>
		            </div>
		            <div class="form-input col-md-8">
		                <input id="stockAmount" name="amount" value="${financialAssetStockEntry.amount}" data-required="true" data-type="number" type="text">
		            </div>
		    	</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-5">
				<div class="form-row">
		            <div class="form-label col-md-4">
		                <label for="postingDate">出入库日期：</label>
		            </div>
		            <div class="form-input col-md-8">
		            	<span class="font-red">出入库日期，需与业务发生日期一致</span>
		            	<input id="postingDate" name="postingDate" value="<#if financialAssetStockEntry.postingDate??>${financialAssetStockEntry.postingDate?string('yyyy-MM-dd HH:mm:ss')}</#if>" data-required="true" onclick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text">
		            </div>
		    	</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-10">
				<a href="javascript:;" class="btn large primary-bg radius-all-4 float-right" onclick="submit('form');">
		            <span class="button-content">保存</span>
                </a>
			</div>
		</div>
		</form>
	</div>
	<!-- #page-content -->
</div>
<!-- #page-content-wrapper -->
<script>

// 提交表单
function submit(formId){
	var valid = $('#' + formId).parsley( 'validate' );
	if(!valid){
		return;
	}
	
	$('#' + formId).submit();
}

</script>